package com.hq.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.hq.dao.CommentMapper;
import com.hq.pojo.Comment;
import com.hq.service.CommentService;
import com.hq.utils.MyBatisUtil;

public class CommentImpl implements CommentService {

	@Override
	public int insertComment(Comment comment) {
		
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			CommentMapper commentMapper = session.getMapper(CommentMapper.class);
			int i  = commentMapper.insertComment(comment);
			return i;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return 0;
	}

	@Override
	public List<Comment> getMoreComment(Integer conver_id, Integer skip) {
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			CommentMapper commentMapper = session.getMapper(CommentMapper.class);
			List<Comment> comments = commentMapper.getMoreComment(conver_id, skip);
			return comments;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return null;
	}

}
